// 方式一
// 时间：104ms - 56.65%
var removeDuplicates = function(nums) {
  let target = null;
  for (let index = nums.length - 1; index > -1; index--) {
    const element = nums[index];
    if (target === element) {
      nums.splice(index, 1);
    } else {
      target = element;
    }
  }
  return nums.length;
};

console.log(removeDuplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4]));
